
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Java 基础 -- 值传递、引用传递和参数传递 · 寒江蓑笠的博客</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="介绍 Java 值传递和引用传递的知识">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="java-basic-stringbuilder-stringbuffer.html" />
    
    
    <link rel="prev" href="java-basic-knowledge-auto-boxing.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="java-basic-joor.html">
            
                <a href="java-basic-joor.html">
            
                    
                    Java 基础 -- 使用 JOOR 实现反射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="java-basic-annotation.html">
            
                <a href="java-basic-annotation.html">
            
                    
                    Java基础 -- 注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="java-basic-threadlocal.html">
            
                <a href="java-basic-threadlocal.html">
            
                    
                    Java 基础 -- ThreadLocal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="java-development-skills-get-stacktrace.html">
            
                <a href="java-development-skills-get-stacktrace.html">
            
                    
                    Java 开发技巧 -- 获取 Java 的调用栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.5" data-path="java-basic-concurrent-map-collection.html">
            
                <a href="java-basic-concurrent-map-collection.html">
            
                    
                    Java 基础 -- 并发集合的使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.6" data-path="java-dynamic-proxy-invocationhandler-demo.html">
            
                <a href="java-dynamic-proxy-invocationhandler-demo.html">
            
                    
                    Java InvocationHandler 实现动态代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.7" data-path="java-basic-try-catch-finally.html">
            
                <a href="java-basic-try-catch-finally.html">
            
                    
                    Java 基础 -- 深入理解 try catch finally
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.8" data-path="java-basic-reflect.html">
            
                <a href="java-basic-reflect.html">
            
                    
                    Java 基础 -- 反射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.9" data-path="java-basic-io-stream.html">
            
                <a href="java-basic-io-stream.html">
            
                    
                    Java IO -- IO流的概念和分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.10" data-path="java-basic-final.html">
            
                <a href="java-basic-final.html">
            
                    
                    Java 基础 -- 深入理解 final 修饰符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.11" data-path="java-basic-memory-manage-constructor.html">
            
                <a href="java-basic-memory-manage-constructor.html">
            
                    
                    Java 内存管理 -- 父子实例的内存控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.12" data-path="java-basic-memory-manage-inherit-object.html">
            
                <a href="java-basic-memory-manage-inherit-object.html">
            
                    
                    Java 内存管理 -- 构造方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.13" data-path="java-basic-memory-manage-memory-area.html">
            
                <a href="java-basic-memory-manage-memory-area.html">
            
                    
                    Java 内存管理 -- 内存区域的划分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.14" data-path="java-basic-memory-manage-variable.html">
            
                <a href="java-basic-memory-manage-variable.html">
            
                    
                    Java 内存管理 -- 变量的内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.15" data-path="java-basic-knowledge-generic.html">
            
                <a href="java-basic-knowledge-generic.html">
            
                    
                    Java 基础 -- 范型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.16" data-path="java-basic-knowledge-auto-boxing.html">
            
                <a href="java-basic-knowledge-auto-boxing.html">
            
                    
                    Java 基础 -- 关于自动装箱和拆箱机制
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.1.17" data-path="java-basic-knowledge-parameter-passing.html">
            
                <a href="java-basic-knowledge-parameter-passing.html">
            
                    
                    Java 基础 -- 值传递、引用传递和参数传递
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.18" data-path="java-basic-stringbuilder-stringbuffer.html">
            
                <a href="java-basic-stringbuilder-stringbuffer.html">
            
                    
                    Java 基础 -- StringBuilder 和 StringBuffer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.19" data-path="java-basic-knowledge-about-string.html">
            
                <a href="java-basic-knowledge-about-string.html">
            
                    
                    Java 基础 -- 深入理解 String
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.20" data-path="java-basic-linkedhashmap.html">
            
                <a href="java-basic-linkedhashmap.html">
            
                    
                    Java 基础 -- LinkedHashMap 的使用和原理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Java 基础 -- 值传递、引用传递和参数传递</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x503C;&#x4F20;&#x9012;&#x548C;&#x5F15;&#x7528;&#x4F20;&#x9012;">&#x503C;&#x4F20;&#x9012;&#x548C;&#x5F15;&#x7528;&#x4F20;&#x9012;</h2>
<p>Java &#x4E2D;&#x5728;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x65F6;&#x6709;2&#x79CD;&#x65B9;&#x5F0F;:</p>
<ol>
<li>&#x503C;&#x4F20;&#x9012;&#xFF1A;&#x503C;&#x4F20;&#x9012;&#x662F;&#x6307;&#x5728;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#x5C06;&#x5B9E;&#x9645;&#x53C2;&#x6570;&#x590D;&#x5236;&#x4E00;&#x4EFD;&#x4F20;&#x9012;&#x5230;&#x51FD;&#x6570;&#x4E2D;&#xFF0C;&#x8FD9;&#x6837;&#x5728;&#x51FD;&#x6570;&#x4E2D;&#x5982;&#x679C;&#x5BF9;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#xFF0C;&#x5C06;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5230;&#x5B9E;&#x9645;&#x53C2;&#x6570;&#x3002;&#x7B80;&#x5355;&#x6765;&#x8BF4;&#x5C31;&#x662F;&#x76F4;&#x63A5;&#x590D;&#x5236;&#x4E86;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#x8FC7;&#x53BB;&#xFF0C;&#x56E0;&#x4E3A;&#x662F;&#x76F4;&#x63A5;&#x590D;&#x5236;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5728;&#x4F20;&#x9012;&#x65F6;&#x5982;&#x679C;&#x6570;&#x636E;&#x91CF;&#x975E;&#x5E38;&#x5927;&#x7684;&#x8BDD;&#xFF0C;&#x8FD0;&#x884C;&#x6548;&#x7387;&#x81EA;&#x7136;&#x5C31;&#x53D8;&#x4F4E;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;java&#x5728;&#x4F20;&#x9012;&#x6570;&#x636E;&#x91CF;&#x5F88;&#x5C0F;&#x7684;&#x6570;&#x636E;&#x662F;&#x503C;&#x4F20;&#x9012;&#xFF0C;&#x6BD4;&#x5982;java&#x4E2D;&#x7684;&#x5404;&#x79CD;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#xFF1A;int,float,double,boolean&#x7B49;&#x7C7B;&#x578B;&#x7684;</li>
<li>&#x5F15;&#x7528;&#x4F20;&#x9012;&#xFF1A;&#x5F15;&#x7528;&#x4F20;&#x9012;&#x5176;&#x5B9E;&#x5C31;&#x5F25;&#x8865;&#x4E86;&#x4E0A;&#x9762;&#x8BF4;&#x7684;&#x4E0D;&#x8DB3;&#xFF0C;&#x5982;&#x679C;&#x6BCF;&#x6B21;&#x4F20;&#x53C2;&#x6570;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x590D;&#x5236;&#x4E00;&#x4EFD;&#x7684;&#x8BDD;&#xFF0C;&#x5982;&#x679C;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x5360;&#x7528;&#x7684;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#x592A;&#x5927;&#x7684;&#x8BDD;&#xFF0C;&#x8FD0;&#x884C;&#x6548;&#x7387;&#x4F1A;&#x5F88;&#x5E95;&#x4E0B;&#xFF0C;&#x6240;&#x4EE5;&#x5F15;&#x7528;&#x4F20;&#x9012;&#x5C31;&#x662F;&#x76F4;&#x63A5;&#x628A;&#x5185;&#x5B58;&#x5730;&#x5740;&#x4F20;&#x8FC7;&#x53BB;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5F15;&#x7528;&#x4F20;&#x9012;&#x65F6;&#xFF0C;&#x64CD;&#x4F5C;&#x7684;&#x5176;&#x5B9E;&#x90FD;&#x662F;&#x6E90;&#x6570;&#x636E;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x8BDD;&#x4FEE;&#x6539;&#x6709;&#x65F6;&#x5019;&#x4F1A;&#x51B2;&#x7A81;&#xFF0C;&#x8BB0;&#x5F97;&#x7528;&#x903B;&#x8F91;&#x5F25;&#x8865;&#x4E0B;&#x5C31;&#x597D;&#x4E86;&#x3002;&#x5177;&#x4F53;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5C31;&#x6BD4;&#x8F83;&#x591A;&#x4E86;&#xFF0C;&#x6BD4;&#x5982;Object&#xFF0C;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#xFF0C;List&#xFF0C;Map&#x7B49;&#x9664;&#x4E86;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;&#x90FD;&#x662F;&#x5F15;&#x7528;&#x4F20;&#x9012;&#x3002;</li>
</ol>
<p>&#x4E0E;&#x6B64;&#x5BF9;&#x5E94;&#x7684;&#xFF0C;Java &#x4E2D;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x6211;&#x4EEC;&#x4E5F;&#x628A;&#x5B83;&#x4EEC;&#x5206;&#x4E3A;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</p>
<ul>
<li>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;<ul>
<li>&#x6574;&#x578B;&#xFF1A;byte&#xFF0C;short&#xFF0C;int&#xFF0C;long</li>
<li>&#x6D6E;&#x70B9;&#x578B;&#xFF1A;float&#xFF0C;double</li>
<li>&#x5B57;&#x7B26;&#x578B;&#xFF1A;char</li>
<li>&#x5E03;&#x5C14;&#x578B;&#xFF1A;boolean</li>
</ul>
</li>
<li>&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;<ul>
<li>&#x6570;&#x7EC4;</li>
<li>&#x7C7B;</li>
<li>&#x63A5;&#x53E3;</li>
</ul>
</li>
</ul>
<p>&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5728;&#x6570;&#x636E;&#x505A;&#x4E3A;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x662F;&#x503C;&#x4F20;&#x9012;&#xFF0C;&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x662F;&#x5F15;&#x7528;&#x4F20;&#x9012;&#xFF08;&#x5730;&#x5740;&#x4F20;&#x9012;&#xFF09;&#x3002;</p>
<h2 id="string&#x7C7B;&#x578B;&#x4F20;&#x9012;">String&#x7C7B;&#x578B;&#x4F20;&#x9012;</h2>
<p>String &#x5728;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x65F6;&#x6BD4;&#x8F83;&#x7279;&#x6B8A;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x6765;&#x770B;&#x4E00;&#x6BB5;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code>public class Example{
    String str=new String(&quot;hello&quot;);
    char[]ch={&apos;a&apos;,&apos;b&apos;};
    public static void main(String args[]){
        Example ex=new Example();
        ex.change(ex.str,ex.ch);
        System.out.print(ex.str+&quot; and &quot;);
        System.out.print(ex.ch);
    }
    public void change(String str,char ch[]){
        str=&quot;test ok&quot;;
        ch[0]=&apos;c&apos;;
    }
}
</code></pre><p>&#x8F93;&#x51FA;&#x7684;&#x7ED3;&#x679C;&#x662F;&#xFF1A;hello and cb
&#x6570;&#x7EC4;&#x8F93;&#x51FA; cb &#x5F88;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#xFF0C;&#x6570;&#x7EC4;&#x662F;&#x5F15;&#x7528;&#x4F20;&#x9012;&#xFF0C;<code>change</code> &#x4E2D;&#x5BF9;&#x6570;&#x7EC4;&#x7684;&#x64CD;&#x4F5C;&#x76F8;&#x5F53;&#x4E8E;&#x6539;&#x53D8;&#x4E86;&#x5806;&#x4E0A;&#x7684;&#x6570;&#x7EC4;&#x7684;&#x503C;&#x3002;
&#x90A3;&#x4E48;String&#x4E5F;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x5C5E;&#x4E8E;&#x5F15;&#x7528;&#x4F20;&#x9012;&#xFF0C;&#x5BF9;&#x5B83;&#x7684;&#x4FEE;&#x6539;&#x4E3A;&#x4EC0;&#x4E48;&#x6CA1;&#x6709;&#x6539;&#x53D8;&#x539F;&#x6765;&#x7684;&#x5BF9;&#x8C61;&#x5462;&#xFF1F;&#x4E3A;&#x4EC0;&#x4E48;&#x770B;&#x8D77;&#x6765;&#x50CF;&#x503C;&#x4F20;&#x9012;&#x5462;&#xFF1F;
&#x5728; String &#x7684;&#x6587;&#x6863;&#x4E2D;&#x6709;&#x4ECB;&#x7ECD;&#xFF1A;
Strings are constant; their values cannot be changed after they are created.
&#x901A;&#x8FC7;&#x6E90;&#x7801;&#x6211;&#x4EEC;&#x8FD8;&#x4F1A;&#x53D1;&#x73B0; <code>String</code> &#x7C7B;&#x662F;final&#x7C7B;&#x578B;&#x7684;&#xFF0C;&#x662F;&#x4E0D;&#x80FD;&#x88AB;&#x7EE7;&#x627F;&#x548C;&#x4FEE;&#x6539;&#x7684;&#x3002;&#x6BCF;&#x4E00;&#x6B21;&#x5185;&#x5BB9;&#x7684;&#x66F4;&#x6539;&#x90FD;&#x662F;&#x91CD;&#x73B0;&#x521B;&#x5EFA;&#x51FA;&#x6765;&#x7684;&#x65B0;&#x5BF9;&#x8C61;&#x3002;
&#x6587;&#x6863;&#x4E2D;&#x8FD8;&#x6709;&#x4ECB;&#x7ECD;&#xFF1A;</p>
<pre><code>String str = &quot;abc&quot;;
</code></pre><p>&#x7B49;&#x540C;&#x4E8E;&#xFF1A;</p>
<pre><code>char data[] = {&apos;a&apos;, &apos;b&apos;, &apos;c&apos;};
String str = new String(data);
</code></pre><p>&#x4E0B;&#x9762;&#x7528;&#x56FE;&#x6765;&#x89E3;&#x91CA;&#x4E00;&#x4E0B;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<p><img src="../../images/java-basic-knowledge-parameter-passing/java-parameter.png" alt="&#x6548;&#x679C;&#x56FE;"></p>
<p><code>change</code> &#x65B9;&#x6CD5;&#x7684; str &#x53C2;&#x6570;&#x672C;&#x6765;&#x5C31;&#x662F; ex.str &#x6240;&#x6307;&#x5411;&#x5730;&#x5740;&#x7684;&#x4E00;&#x4E2A; copy&#xFF0C;&#x5F53; <code>change</code> &#x65B9;&#x6CD5;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#x65F6;&#xFF0C;str &#x6240;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;&#x503C;&#x5DF2;&#x7ECF;&#x6539;&#x53D8;&#x3002;&#x800C; str &#x672C;&#x6765;&#x7684;&#x5730;&#x5740;&#x503C;&#x5C31;&#x662F;copy&#x8FC7;&#x6765;&#x7684;&#x526F;&#x672C;&#xFF0C;&#x6240;&#x4EE5;&#x5E76;&#x4E0D;&#x80FD;&#x6539;&#x53D8; ex.str &#x8FD9;&#x4E2A;&#x996E;&#x7528;&#x6240;&#x6307;&#x5411;&#x7684;&#x5BF9;&#x8C61;&#x7684;&#x503C;&#x3002;</p>
<p>String &#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7C7B;&#x4F3C;&#xFF1A;</p>
<pre><code>class Person {
    String name;

    public Person(String name) {
        this.name = name;
    }
}
public class Test {
    public static void main(String[] args) {
        Person p = new Person(&quot;&#x5F20;&#x4E09;&quot;);

        change(p);

        System.out.println(p.name);
    }

    public static void change(Person p) {
        Person person = new Person(&quot;&#x674E;&#x56DB;&quot;);
        p = person; 
    }
}
</code></pre><p>&#x8FD0;&#x884C;&#x7684;&#x7ED3;&#x679C;&#x662F;&#xFF1A;</p>
<pre><code>&#x5F20;&#x4E09;
</code></pre><h2 id="&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x673A;&#x5236;">&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x673A;&#x5236;</h2>
<p>&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x5206;&#x4E3A;&#x4E24;&#x79CD;&#xFF1A;</p>
<ul>
<li>&#x5F62;&#x5F0F;&#x53C2;&#x6570;&#xFF1A;&#x5B9A;&#x4E49;&#x65B9;&#x6CD5;&#x65F6;&#x58F0;&#x660E;&#x7684;&#x53C2;&#x6570;</li>
<li>&#x5B9E;&#x9645;&#x53C2;&#x6570;&#xFF1A;&#x8C03;&#x7528;&#x65B9;&#x6CD5;&#x65F6;&#x4F20;&#x7ED9;&#x5F62;&#x53C2;&#x7684;&#x5177;&#x4F53;&#x53C2;&#x6570;&#x503C;</li>
</ul>
<p>&#x90A3;&#x4E48;&#xFF0C;Java&#x7684;&#x5B9E;&#x53C2;&#x503C;&#x662F;&#x5982;&#x4F55;&#x4F20;&#x5165;&#x65B9;&#x6CD5;&#x7684;&#x5462;&#xFF1F;&#x8FD9;&#x662F;&#x7531; Java &#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x673A;&#x5236;&#x6765;&#x63A7;&#x5236;&#x7684;&#xFF0C;Java &#x91CC;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x65B9;&#x5F0F;&#x53EA;&#x6709;&#x4E00;&#x79CD;&#xFF1A;&#x503C;&#x4F20;&#x9012;&#x3002;
&#x6240;&#x8C13;&#x7684;&#x503C;&#x4F20;&#x9012;&#x5C31;&#x662F;&#x5C06;&#x5B9E;&#x9645;&#x53C2;&#x6570;&#x503C;&#x7684;&#x526F;&#x672C;&#xFF08;&#x590D;&#x5236;&#x54C1;&#xFF09;&#x4F20;&#x5165;&#x65B9;&#x6CD5;&#x5185;&#xFF0C;&#x800C;&#x53C2;&#x6570;&#x672C;&#x8EAB;&#x4E0D;&#x4F1A;&#x6536;&#x5230;&#x4EFB;&#x4F55;&#x5F71;&#x54CD;&#x3002;
&#x7ED3;&#x5408;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x7B80;&#x5355;&#x70B9;&#x5C06;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x6765;&#x4F20;&#x9012;&#xFF0C;&#x8FD9;&#x65F6;&#x4F20;&#x9012;&#x7684;&#x65F6;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x6307;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x5730;&#x5740;&#x7684;&#x4E00;&#x4E2A;copy&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x4FEE;&#x6539;&#x5B83;&#x7684;&#x5C5E;&#x6027;&#x4EC0;&#x4E48;&#x7684;&#xFF0C;&#x867D;&#x7136;&#x5B83;&#x662F;&#x4E00;&#x4E2A;copy&#xFF0C;&#x4F46;&#x5B83;&#x4EEC;&#x6267;&#x884C;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#xFF0C;&#x90A3;&#x4E48;&#x4FEE;&#x6539;&#x7684;&#x4ECD;&#x7136;&#x662F;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;&#x8FD9;&#x65F6;&#x5982;&#x679C;&#x4F60;&#x7ED9;&#x5B83;&#x91CD;&#x65B0;&#x8D4B;&#x503C;&#xFF0C;&#x5C31;&#x662F;&#x4FEE;&#x6539;&#x5B83;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;&#xFF0C;&#x90A3;&#x4E48;&#x53EA;&#x662F;&#x4FEE;&#x6539;&#x4E86;&#x8FD9;&#x4E2A;copy&#x7684;&#x5730;&#x5740;&#xFF0C;&#x539F;&#x6765;&#x7684;&#x5F15;&#x7528;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;&#x4ECD;&#x7136;&#x662F;&#x4E0D;&#x53D7;&#x5F71;&#x54CD;&#x7684;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5C06;change&#x65B9;&#x6CD5;&#x7684;&#x4EE3;&#x7801;&#x6539;&#x6210;&#xFF1A;</p>
<pre><code>    public  void change(Person p) {
        //Person person = new Person(&quot;&#x674E;&#x56DB;&quot;);
        //p = person;
        p.name = &quot;&#x674E;&#x56DB;&quot;;
    }
</code></pre><p>&#x8FD0;&#x884C;&#x7684;&#x7ED3;&#x679C;&#x662F;&#xFF1A;</p>
<pre><code>&#x674E;&#x56DB;
</code></pre><h2 id="&#x603B;&#x7ED3;">&#x603B;&#x7ED3;</h2>
<ul>
<li>&#x503C;&#x4F20;&#x9012;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C06;&#x5B9E;&#x53C2;&#x7684;&#x503C;&#xFF0C;copy &#x4E00;&#x4EFD;&#x7ED9;&#x5F62;&#x53C2;&#x3002;</li>
<li>&#x5F15;&#x7528;&#x4F20;&#x9012;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C06;&#x5B9E;&#x53C2;&#x7684;&#x5730;&#x5740;&#x503C;&#xFF0C;copy &#x4E00;&#x4EFD;&#x7ED9;&#x5F62;&#x53C2;&#x3002;</li>
</ul>
<p>&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x4E0D;&#x7BA1;&#x662F;&#x503C;&#x4F20;&#x9012;&#x8FD8;&#x662F;&#x5F15;&#x7528;&#x4F20;&#x9012;&#xFF0C;&#x5F62;&#x53C2;&#x62FF;&#x5230;&#x7684;&#x4EC5;&#x4EC5;&#x662F;&#x5B9E;&#x53C2;&#x7684;&#x526F;&#x672C;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x5B9E;&#x53C2;&#x672C;&#x8EAB;&#x3002;</p>
<h2 id="&#x53C2;&#x8003;">&#x53C2;&#x8003;</h2>
<p>&#x300A;&#x75AF;&#x72C2; Java &#x8BB2;&#x4E49;&#x300B;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="java-basic-knowledge-auto-boxing.html" class="navigation navigation-prev " aria-label="Previous page: Java 基础 -- 关于自动装箱和拆箱机制">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="java-basic-stringbuilder-stringbuffer.html" class="navigation navigation-next " aria-label="Next page: Java 基础 -- StringBuilder 和 StringBuffer">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Java 基础 -- 值传递、引用传递和参数传递","categories":"Java","comments":true,"tags":["Java"],"description":"介绍 Java 值传递和引用传递的知识","date":"2014-02-10T10:00:00.000Z","level":"1.1.17","depth":2,"next":{"title":"Java 基础 -- StringBuilder 和 StringBuffer","level":"1.1.18","depth":2,"path":"source/Java/java-basic-stringbuilder-stringbuffer.md","ref":"source/Java/java-basic-stringbuilder-stringbuffer.md","articles":[]},"previous":{"title":"Java 基础 -- 关于自动装箱和拆箱机制","level":"1.1.16","depth":2,"path":"source/Java/java-basic-knowledge-auto-boxing.md","ref":"source/Java/java-basic-knowledge-auto-boxing.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"expandable-chapters":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"寒江蓑笠的博客","gitbook":"*"},"file":{"path":"source/Java/java-basic-knowledge-parameter-passing.md","mtime":"2022-05-17T10:49:59.386Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-05-17T10:54:58.084Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

